﻿<phone:PhoneApplicationPage x:Class="SAFPodcast.WP8.ViewFeedView"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
    xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:ignore="http://www.ignore.com"
    xmlns:toolkit="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit"
    xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity" 
    xmlns:MvvmLight="clr-namespace:GalaSoft.MvvmLight.Command;assembly=GalaSoft.MvvmLight.Extras.WP8"
    xmlns:converters="clr-namespace:SAFPodcast.WP8.Fwk.Converter;assembly=SAFPodcast.WP8.Fwk"
    mc:Ignorable="d ignore"
    d:DesignWidth="480"
    d:DesignHeight="768"
    FontFamily="{StaticResource PhoneFontFamilyNormal}"
    FontSize="{StaticResource PhoneFontSizeNormal}"
    Foreground="{StaticResource PhoneForegroundBrush}"
    SupportedOrientations="Portrait"
    Orientation="Portrait"
    shell:SystemTray.IsVisible="True"
    DataContext="{Binding ViewFeed, Source={StaticResource Locator}}">

  <phone:PhoneApplicationPage.Resources>
    <converters:VisibilityConverter x:Key="VisibilityConverter" />
  </phone:PhoneApplicationPage.Resources>

  <Grid x:Name="LayoutRoot" Background="Transparent">
    <phone:Pivot Title="{Binding Path=Global.ViewFeed_Title, Source={StaticResource LocalizedStrings}}">
      <phone:PivotItem Header="{Binding FeedName}">
        <Grid>
          <Grid.RowDefinitions>
            <RowDefinition Height="*" />
          </Grid.RowDefinitions>
          <ListBox x:Name="lbItems" Grid.Row="1" ItemsSource="{Binding FeedItems}">
            <toolkit:GestureService.GestureListener>
              <toolkit:GestureListener />
            </toolkit:GestureService.GestureListener>
            <ListBox.ItemTemplate>
              <DataTemplate>
                <Grid Margin="0,0,0,17" Width="432" Height="78" toolkit:TiltEffect.IsTiltEnabled="True">
                  <Grid.RowDefinitions>
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="*" />
                  </Grid.RowDefinitions>
                  <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="Auto" />
                    <ColumnDefinition Width="*" />
                  </Grid.ColumnDefinitions>

                  <Image Width="43" Height="43" Source="/Toolkit.Content/basecircle.png" Grid.Row="0" Grid.Column="0" />
                  <Image Width="43" Height="43" Source="/Toolkit.Content/transport.play.png" Grid.Row="0" Grid.Column="0" />
                  <TextBlock Text="{Binding Title}"
                    TextWrapping="NoWrap" Grid.Row="0" Grid.Column="1"
                    Style="{StaticResource PhoneTextExtraLargeStyle}" />
                  <ProgressBar Value="{Binding DownloadProgress, Mode=OneWay}" Maximum="100"
                    Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="2"
                    Visibility="{Binding IsDownloading, Converter={StaticResource VisibilityConverter}, Mode=OneWay}" />
                  <i:Interaction.Triggers>
                    <i:EventTrigger EventName="Tap">
                      <MvvmLight:EventToCommand
                        Command="{Binding ElementName=lbItems, Path=DataContext.Play}"
                        CommandParameter="{Binding SelectedItem, ElementName=lbItems}" />
                    </i:EventTrigger>
                  </i:Interaction.Triggers>

                  <toolkit:ContextMenuService.ContextMenu>
                    <toolkit:ContextMenu IsZoomEnabled="True">
                      <toolkit:MenuItem Header="Download"
                          Command="{Binding ElementName=lbItems, Path=DataContext.Download}"
                          CommandParameter="{Binding}" />
                    </toolkit:ContextMenu>
                  </toolkit:ContextMenuService.ContextMenu>
                </Grid>
              </DataTemplate>
            </ListBox.ItemTemplate>
          </ListBox>
        </Grid>
      </phone:PivotItem>
    </phone:Pivot>
  </Grid>

  <toolkit:TransitionService.NavigationInTransition>
    <toolkit:NavigationInTransition>
      <toolkit:NavigationInTransition.Backward>
        <toolkit:TurnstileTransition Mode="BackwardIn"/>
      </toolkit:NavigationInTransition.Backward>
      <toolkit:NavigationInTransition.Forward>
        <toolkit:TurnstileTransition Mode="ForwardIn"/>
      </toolkit:NavigationInTransition.Forward>
    </toolkit:NavigationInTransition>
  </toolkit:TransitionService.NavigationInTransition>
  <toolkit:TransitionService.NavigationOutTransition>
    <toolkit:NavigationOutTransition>
      <toolkit:NavigationOutTransition.Backward>
        <toolkit:TurnstileTransition Mode="BackwardOut"/>
      </toolkit:NavigationOutTransition.Backward>
      <toolkit:NavigationOutTransition.Forward>
        <toolkit:TurnstileTransition Mode="ForwardOut"/>
      </toolkit:NavigationOutTransition.Forward>
    </toolkit:NavigationOutTransition>
  </toolkit:TransitionService.NavigationOutTransition>
</phone:PhoneApplicationPage>
